<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script>

        // 如何交换两个变量的值

        var a = 1, b = 2;

        // a = b ;   // a = b = 2 ;   ->  a = 2

        // b = a ;   // b = a = 2   ->  b = 2

        // console.log(a) ;


        // 一个叫a的杯子装了咖啡 ， 一个叫b的杯子装了可乐

        // 解决：再搞一个杯子


        var c ;
        // 把等号右边的给左边
        c = a ;
        a = b ;
        b = c ;

        console.log(a , b);

    </script>

</body>

</html>